<?php

namespace app\api\model;

class User extends BaseModel {
    protected $name = 'users';

    public function getAll($params) {
        $size = isset($params['size']) && $params['size'] >= 1 ? $params['size'] : 1;
        return self::field('id,name,email')->paginate($size);
    }

    public function getOne($id) {
        return self::field('id,name,email')->where('id', $id)->find();
    }

    public function records() {
        return $this->hasMany(Record::class, 'user_id');
    }
}